/* eslint valid-jsdoc: "off" */

'use strict';

/**
 * @param {Egg.EggAppInfo} appInfo app info
 */
module.exports = appInfo => {
  /**
   * built-in config
   * @type {Egg.EggAppConfig}
   **/
  const config = exports = {};

  // use for cookie sign key, should change to your own and keep security
  config.keys = appInfo.name + '_1600136943580_346';

  // add your middleware config here
  config.middleware = [];

  // add your user config here
  const userConfig = {
    // myAppName: 'egg',
  };

  // 禁用csrf防御
  config.security = {
    csrf: {
      enable: false,
    },
  };

  config.view = {
    // 默认的模板拓展名
    defaultExtension: '.html',
    // 默认的模板引擎
    defaultViewEngine: 'nunjucks',
  };

  config.session = {
    key: 'weibo-sess', // session加密后的值的前缀
    maxAge: 30 * 60 * 1000, // session 过期时间 单位是毫秒
    httpOnly: true, // 前端不能修改 默认就是true
    encrypt: true, // 传输过程中加密
  };

  config.redis = {
    client: {
      host: '127.0.0.1',
      port: 6379,
      password: '',
      db: '0',
    },
    agent: true,
  };

  // 设置静态文件目录
  config.static = {
    prefix: '/',
    // 将app/public文件夹设置为静态文件目录
    dir: appInfo.baseDir + '/app/public',
  };

  config.sequelize = {
    dialect: 'mysql',
    host: '127.0.0.1',
    port: 3306,
    username: 'root',
    password: '',
    database: 'egg-weibo-test',
  };

  config.ajv = {
    keyword: 'schema',
    allErrors: true,
    jsonPointers: true,
  };

  // 文件上传
  config.multipart = {
    mode: 'file',
    fileSize: '2mb',

  };

  return {
    ...config,
    ...userConfig,
  };
};
